function main() {
    debugger
    let self = this;
    let treeEle = self.$$("tree_panel_1e67fs");
    let selectedData = treeEle.selectedData;

    let groupTreeEle = self.$$("tree_panel_82bw1d");
    let selectedGroupData = groupTreeEle.selectedData[0];
    const groupId = selectedGroupData.id;


    if (!selectedData || selectedData.length === 0) {
        console.log("没有数据可供处理");
        // 可以弹出提示框或者执行其他操作
        self.$message.warning("请最少添加一条认领主体！")
        return;
    }

    // 保存之前删除之前的数据
    deleteLawUnitMatterGroupDepRel(groupId).then(r => {
        console.log(r);
        for (let i = 0; i < selectedData.length; i++) {
            let groupDepData = selectedData[i];
            insertLawUnitMatterGroupDepRel(groupId, groupDepData).then(r => {
                console.log(r);
            });
        }
    })



}

/**
 * 	law_unit_matter_group_dep_rel
 * @param groupId
 */
function deleteLawUnitMatterGroupDepRel(groupId) {

    const law_unit_matter_group_dep_rel = "ds_tbl:t_818be4f1aa344dc68eab3fcdb2021675";
    const deleteSql = `DELETE('${law_unit_matter_group_dep_rel}', QUERY_EQ('group_id', ${groupId}),'')`;
    console.log(deleteSql);

    return new Promise((resolve, reject) => {
        api.EXEC_FORMULA(deleteSql).then(res => {
            console.log(res);
            resolve(res);})
    })
}


/**
 * law_unit_matter_group_dep_rel
 * @param groupId
 * @param groupDepData
 */
function insertLawUnitMatterGroupDepRel(groupId, groupDepData) {

    const lawUnitMatterGroupDepRel = [
        ['group_id', groupId],
        ['enforment_id', groupDepData.unit_id],
        ['create_time', 'NOW()']
    ];

    const formattedFields = lawUnitMatterGroupDepRel.map(([key, value]) => {
        return `'${key}',${value}`;
    });

    const law_unit_matter_group_dep_rel = "ds_tbl:t_818be4f1aa344dc68eab3fcdb2021675";
    const insertSql = `INSERT('${law_unit_matter_group_dep_rel}', [${formattedFields.join(',')}])`;
    console.log(insertSql);


    return new Promise((resolve, reject) => {
        api.EXEC_FORMULA(insertSql).then(res => {
            console.log(res);
            resolve(res);
        })
    })

}
